using AutoMapper;
using SmartLink.Domain.Entity;
using SmartLink.Domain.ExpandEntity;
using SmartLink.DTOS.Permission;
using SmartLink.DTOS.SysBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Infrastructure.Mappers
{
    public class SysModuleToDtoProfile : Profile
    {
        public SysModuleToDtoProfile()
        {
            CreateMap<SYS_Module, SysModuleDTO>().ReverseMap();
            CreateMap<SYS_Module, SysModuleTreeNodeDTO>()
                .ForMember(d => d.MenuName, opt => opt.MapFrom(a => a.Name));
            CreateMap<SYS_ModuleFunction, SysModuleFunctionDTO>().ReverseMap();
            CreateMap<SYS_ModuleFunction, SysModuleFunctionNodeDTO>()
                .ForMember(d => d.FunctionID, opt => opt.MapFrom(a => a.ID));
            CreateMap<SYS_Module, SysModuleFunctionTreeNodeDTO>()
                .ForMember(d => d.ModuleID, opt => opt.MapFrom(a => a.ID));
            CreateMap<SysModuleExpand, SysModuleFunctionTreeNodeDTO>()
             .ForMember(d => d.ModuleID, opt => opt.MapFrom(a => a.ID));
            CreateMap<SysModuleTreeNodeDTO, SysModuleDTO>()
                .ForMember(d => d.Name, opt => opt.MapFrom(a => a.MenuName));
            CreateMap<SysModuleTreeNodeDTO, SysModuleWithFunctionsListItemDTO>()
                .ForMember(d => d.Name, opt => opt.MapFrom(a => a.MenuName));

            CreateMap<SYS_Module, PermissionListItemDTO>();
            CreateMap<SysModuleWithFunctionsListItemDTO, PermissionListItemViewDTO>();//父类转子类
        }
    }
}
